<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ include file="commons/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<title></title>
<link rel="stylesheet" href="${ctx }/static/css/pintuer.css">
<link rel="stylesheet" href="${ctx }/static/css/admin.css">
<script src="${ctx }/static/js/jquery.js"></script>
<script src="${ctx }/static/js/pintuer.js"></script>

<%-- <script type="text/javascript">
	<%if (session.getAttribute("loginMessage") == null) {%>
		alert("请登录后访问！");                        /*  验证是否存在ID，若没有表示没登录 */
	 	/* window.location.href='login'; */
	 	window.parent.location.href='${ctx }/login';
	<%}%>
	</script> --%>
</head>
<body>
	<div class="panel admin-panel margin-top">
		<div class="panel-head" id="add">
			<strong><span class="icon-pencil-square-o"></span>编辑预约</strong>
		</div>
		<div class="body-content">
			<form method="post" class="form-x" action="doEdit">
			<input type="hidden" name="id" value="${editId }"/>
				<div class="form-group">
					<div class="label">
						<label>医院分类：</label>
					</div>
					<div class="field" style="width: 30%">
						<select name="hospitalName" class="hospitalName"
							style="width: 75%">
							<c:forEach items="${branchCourts }" var="branchCourts">
								<option name="hospitalName" value="${branchCourts.hospitalName}"
									id="${branchCourts.id }">${branchCourts.hospitalName}</option>
							</c:forEach>
						</select>
					</div>
					<div class="field">
						<div class="address" style="float: left; padding-top: 10px">
							<label>医院地址：</label>
						</div>
						<select name="address" class="address" style="float: left;">
							<option value="">请选择医院所在地</option>
							<option value="四川省成都市">四川省成都市</option>
							<option value="北京市">北京市</option>
						</select>
					</div>
				</div>

				<div class="form-group">
					<div class="label">
						<label>医院服务热线：</label>
					</div>
					<div class="field">
						<select name="tele" class="tele">
						</select>
						<div class="tips"></div>
					</div>
				</div>
				<div class="form-group">
					<div class="label">
						<label>就诊科室：</label>
					</div>
					<div class="field">
						<select name="departments" class="departments">
							<option value="">请选择就诊科室</option>
							<c:forEach items="${ department}" var="department">
								<option name="department" value="${department.departments}" id="${department.id }">${department.departments }</option>

							</c:forEach>
						</select>
						<div class="tips"></div>
					</div>
				</div>
				<div class="form-group">
					<div class="label">
						<label>主治医生：</label>
					</div>
					<div class="field">
						<select name="doctor" class="doctor" id="doctor">
							<option value="">请选择主治医师</option>
							<c:forEach items="${ doctors}" var="doctor">
								<option name="doctor" value="${doctor.name}" id="${doctor.id }">${doctor.name }</option>
							</c:forEach>
						</select>
						<div class="tips"></div>
					</div>
				</div>
				<div class="form-group">
					<div class="label">
						<label>预约所定日期：</label>
					</div>
					<div class="field">
						 <input name="date" type="text" class="sang_Calender" />
					</div>
				</div>
				<div class="form-group">
					<div class="label">
						<label>医师邮箱：</label>
					</div>
					<div class="field">
						<input type="text" id="email" class="input" name="email" value="" />
					</div>
				</div>
				<div class="form-group">
					<div class="label" style="float: left;">
						<label>医生联系电话：</label>
					</div>
					<div class="doctorTele" style="float: left; width: 45%">
						<input type="text" id="doctorTele" class="input" name="doctorTele"
							value="" />
					</div>
				</div>
				

				<div class="form-group">
					<div class="label">
						<label></label>
					</div>
					<div class="field">
						<button class="button bg-main icon-check-square-o" type="submit">修改</button>
					</div>
				</div>
			</form>
		</div>
	</div>
	<script type="text/javascript">
$(".hospitalName").click(function() {
	$(".address").empty();
	$(".tele").empty();
	console.log($(".hospitalName").val());
	 $.post('ajax',{
				pa:$(".hospitalName").val()      //给别名pa赋值
			},function(e){
				console.log(e);
				  for(var i=0; i<e.length;i++){
          	$(".address").append("<option value='"+e[i].address+"'>"+e[i].address+"</option>");
          	$(".tele").append("<option value='"+e[i].tele+"'>"+e[i].tele+"</option>");
          			//把e中的地址拿出来，显示在地址的option中
         } 
			 }); 
});


$(".departments").click(function() {
	$('.doctor').empty();
	//alert($(this).find("option:checked").attr("id"));         //选择科室后,alert出选择项的id
	//alert($(".hospitalName").find("option:checked").attr("id"));         
	 $.post('ajax1',{
				branch_id:$(".hospitalName").find("option:checked").attr("id"),
				depart_id:$(".departments").find("option:checked").attr("id")
			},function(e){
				console.log(e);
				  for(var i=0; i<e.length;i++){
          	$(".doctor").append("<option id='"+e[i].id+"' value='"+e[i].name+"'>"+e[i].name+"</option>");
          	//$("#doctorTele")[i].value=e[i].tele;				//修改input中的值，显示号码
          	//$("#email")[i].value=e[i].email;				//修改input中的值，显示号码
          			//把e中的医师名字拿出来，显示在option中
         } 
			 }); 
});

$(".doctor").click(function() {
	var id=$("#doctor option:selected").attr("id");       //select选中option,拿到option的id
	console.log(id);
	 $.post('ajax2',{
		doctor_id:id
	},function(e){ 
		$("#doctorTele")[0].value=e[0].tele;
		$("#email")[0].value=e[0].email;
		
	 }) 
	
});
</script>
<script type="text/javascript" src="${ctx }/static/js/datetime.js"></script>

</body>
</html>